#ifndef TC_TESTHARNESS_HH
#define TC_TESTHARNESS_HH

/** \file TestHarness.hh 
 * Declarations for class TestHarness and inclusions which
 * provide single inclusion file to write test cases.
 *
 * (c) Copyright 2003-2006 by Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: TestHarness.hh 119 2006-06-21 04:57:25Z semihc $
 *
 *
 */

#include <string>
#include <vector>
#include <iostream>
#include "Null.hh"
#include "Ex.hh"
#include "Debug.hh"
#include "gtest/gtest.h"


namespace TC {

  //! Generic "print-elements" function to dump a collection.
  //! See C++StdLib book page 118.
  template <typename T>
  inline void PrintElements(const T& col, 
                            const char* cmnt=NullStr)
  {
    std::ostream& os = Debug(Debug::e_Info,__FILE__,__LINE__).getStream();
    typename T::const_iterator pos;
     
     os << cmnt << '[';
     for(pos=col.begin(); pos!=col.end(); ++pos) {
       if(pos!=col.begin()) 
         os << ',';
       os << *pos;
     }
     os << ']' << std::endl;
   }


   //! Generic "insert-elements" function to populate a container.
   //! See C++StdLib book page 333.
   template <typename T>
   inline void InsertElements(T& col, int first, int last)
   {
     for(int i=first; i<=last; ++i)
       col.insert(col.end(),i);
   }


   //! Check if a Floating-Point number is within
   //! a confidence level of a expected value.
   inline bool CheckFP(const double exp, //!< Expected value 
                       const double val, //!< Actual value
                       double conf=0.01) //!< Confidence percentage
   {
     register double confval = exp * conf;
     if( val > exp+confval ||
         val < exp-confval )
       return false; // Outside of confidence interval
     else
       return true;  // Inside the confidence interval
   }


// Defined for migration to gtest
#define TC_TEST(T) EXPECT_TRUE(T)
#define TC_TESTFP(A,B)  ::TC::CheckFP(A,B)
#define TC_TESTFPC(A,B,C)  ::TC::CheckFP(A,B,C)



} // end namespace



#endif /* Include guard */
